package de.fhhannover.inform.itteam.snmpnetviz;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Set;

public class IpToMac {
	private HashMap<String, String> mIpToMac=new HashMap<String, String>();
	private HashMap<String, String> mMacToIp=new HashMap<String, String>();
	
	public void addEntry(String ip, String mac) {
		mIpToMac.put(ip, mac);
		mMacToIp.put(mac, ip);
	}
	
	public void addIpMacTable(IpToMac ipMacTable) {
		Iterator<Entry<String, String>> it = ipMacTable.getIpMacBundles();
		while (it.hasNext()) {
			Entry<String, String> next = it.next();
			this.addEntry(next.getKey(), next.getValue());
		}
	}
	
	public Iterator<Entry<String, String>> getIpMacBundles() {
		Set<Entry<String, String>> entrySet = mIpToMac.entrySet();
		return entrySet.iterator();
	}
	
	public String getIpForMac(String mac) {
		return mMacToIp.get(mac);
	}
	
	public String getMacForIp(String ip) {
		return mIpToMac.get(ip);
	}

}
